package org.kukker.spinner;

import java.util.Map;

import android.content.Context;
import android.database.DataSetObserver;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsoluteLayout;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.LinearLayout.LayoutParams;

public class KukkerSpinnerAdapter implements SpinnerAdapter {

	Context mContext;
	Button mAutoDetectBtn;
	EditText mManualEntry;
	
	public void setContext(Context context){
		this.mContext = context;
	}
	
	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Log.i("agus","getDropdownView");
		return this.getView(position, convertView, parent);
		
		
	}

	@Override
	public View getMeasurementView(ViewGroup arg0) {
		Log.i("agus","getMeasurementView");
		// TODO Auto-generated method stub
		
		
		
		LinearLayout abs = new LinearLayout(this.mContext);
		LayoutParams lp;
		abs.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
		return abs;		
	}

	@Override
	public int getCount() {
		Log.i("agus","getCount");
		// TODO Auto-generated method stub
		return 2;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		
		return new Object();
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getNewSelectionForKey(int currentSelection, int keyCode,
			KeyEvent event) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Log.i("agus","getView, position:"+position);
		//manual
		if(position == 1 )
		{
			EditText editText = new EditText(this.mContext);			
			return editText;
		}
		
		//autodetect current position		
		else if(position == 2){
			Button btn =  new Button(this.mContext);
			btn.setText("Auto Detect");
			return btn;
		}
		
		Button btn =  new Button(this.mContext);
		btn.setText("Auto Detect");
		return btn;
	
	}

	@Override
	public void registerDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean stableIds() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void unregisterDataSetObserver(DataSetObserver arg0) {
		// TODO Auto-generated method stub
		
	}

	
	
	
}